package jjn.carl.dp;

import java.util.Scanner;

/**
 * @author Jjn
 * @since 2023/8/4 23:44
 */
public class LeetCode509 {
    public int fib(int n) {
        if (n <= 1) {
            return n;
        }
        int[] dp = new int[2];
        dp[1] = 1;
        int sum = 0;
        for (int i = 2; i <= n; i++) {
            sum = dp[0] + dp[1];
            dp[0] = dp[1];
            dp[1] = sum;
        }
        return sum;
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int fib = new LeetCode509().fib(n);
            System.out.println(fib);
        }
    }
}
